﻿
@{
    Layout = null;
}




<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>注册 - layuiAdmin</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link href="~/Content/layuiadmin/layui/css/layui.css" rel="stylesheet" />
    <link href="~/Content/layuiadmin/style/admin.css" rel="stylesheet" />
    <link href="~/Content/layuiadmin/style/login.css" rel="stylesheet" />
</head>
<body>


    <div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login" style="display: none;">
        <div class="layadmin-user-login-main">
            <div class="layadmin-user-login-box layadmin-user-login-header">
                <h2>layuiAdmin</h2>
                <p>layui 官方出品的单页面后台管理模板系统</p>
            </div>
            <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
                <div class="layui-form-item">
                    <label class="layadmin-user-login-icon layui-icon layui-icon-username" for="LAY-user-login-username"></label>
                    <input type="text" name="username" id="LAY-user-login-username" lay-verify="required" placeholder="用户名" class="layui-input">
                </div>
                <div class="layui-form-item">
                    <label class="layadmin-user-login-icon layui-icon layui-icon-password" for="LAY-user-login-password"></label>
                    <input type="password" name="password" id="LAY-user-login-password" lay-verify="pass" placeholder="密码" class="layui-input">
                </div>
                <div class="layui-form-item">
                    <label class="layadmin-user-login-icon layui-icon layui-icon-password" for="LAY-user-login-repass"></label>
                    <input type="password" name="repass" id="LAY-user-login-repass" lay-verify="required" placeholder="确认密码" class="layui-input">
                </div>
                <div class="layui-form-item">
                    <label class="layadmin-user-login-icon layui-icon layui-icon-username" for="LAY-user-login-nickname"></label>
                    <input type="text" name="nickname" id="LAY-user-login-nickname" lay-verify="nickname" placeholder="昵称" class="layui-input">
                </div>
                <div class="layui-form-item">
                    <button class="layui-btn layui-btn-fluid" lay-submit id="add" lay-filter="LAY-user-reg-submit">注 册</button>
                </div>
                <div class="layui-trans layui-form-item layadmin-user-login-other">
                    <label>社交账号注册</label>
                    <a href="javascript:;"><i class="layui-icon layui-icon-login-qq"></i></a>
                    <a href="javascript:;"><i class="layui-icon layui-icon-login-wechat"></i></a>
                    <a href="javascript:;"><i class="layui-icon layui-icon-login-weibo"></i></a>

                    <a href="@Url.Action("Login")" class="layadmin-user-jump-change layadmin-link layui-hide-xs">用已有帐号登入</a>
                    <a href="login.html" class="layadmin-user-jump-change layadmin-link layui-hide-sm layui-show-xs-inline-block">登入</a>
                </div>
            </div>
        </div>

        <div class="layui-trans layadmin-user-login-footer">

            <p>© 2018 <a href="http://www.layui.com/" target="_blank">layui.com</a></p>
            <p>
                <span><a href="http://www.layui.com/admin/#get" target="_blank">获取授权</a></span>
                <span><a href="http://www.layui.com/admin/pro/" target="_blank">在线演示</a></span>
                <span><a href="http://www.layui.com/admin/" target="_blank">前往官网</a></span>
            </p>
        </div>

    </div>

    <script src="~/Content/layuiadmin/layui/layui.js"></script>
    <script>
        layui.config({
            base: '/Content/layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'user'], function () {
            var $ = layui.$
                , setter = layui.setter
                , admin = layui.admin
                , form = layui.form
                , router = layui.router();

            form.render();

            //注册逻辑
            $("#add").click(function () {
                var username = $("#LAY-user-login-username").val();
                var password = $("#LAY-user-login-password").val();
                var repass = $("#LAY-user-login-repass").val();
                var nickname = $("#LAY-user-login-nickname").val();

                if (username.trim().length <= 0) {
                    layer.msg("用户名不能为空");
                    return;
                }
                if (password.trim().length == 0) {
                    layer.msg("密码不能为空");
                    return;
                }
                //确认密码
                if (password !== repass) {
                    return layer.msg('两次密码输入不一致');
                }

                var admin = {
                    AdminName: username,
                    PassWord: password,
                    NickName: nickname
                }
                $.post("http://localhost:62799/api/AdminUser/Reg", admin, function (res) {
                    if (res.Code == 200) {
                        layer.msg("注册成功");
                        datatable.ajax.reload();
                        setTimeout(() => {
                            location.href = "/AdminUser/Login";
                        },1500)
                    }
                    else {
                        layer.msg("注册失败");
                    }
                })
            })
        });
    </script>
</body>
</html>
